using System.Threading.Tasks;
using System;

namespace DesktopWidgetApp.Server.Models
{
    /// <summary>
    /// 用户服务接口
    /// </summary>
    public interface IUserService
    {
        /// <summary>
        /// 注册新用户
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="email">邮箱</param>
        /// <param name="password">密码</param>
        /// <returns>注册结果</returns>
        Task<(bool success, string message, User user)> RegisterUserAsync(string username, string email, string password);
        
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <returns>登录结果</returns>
        Task<(bool success, string message, string token)> LoginAsync(string username, string password);
        
        /// <summary>
        /// 根据ID获取用户
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns>用户信息，可能为null</returns>
        Task<User?> GetUserByIdAsync(Guid userId);
        
        /// <summary>
        /// 根据用户名获取用户
        /// </summary>
        /// <param name="username">用户名</param>
        /// <returns>用户信息，可能为null</returns>
        Task<User?> GetUserByUsernameAsync(string username);
        
        /// <summary>
        /// 更新用户信息
        /// </summary>
        /// <param name="user">用户信息</param>
        /// <returns>更新结果</returns>
        Task<(bool success, string message)> UpdateUserAsync(User user);
        
        /// <summary>
        /// 验证JWT令牌
        /// </summary>
        /// <param name="token">JWT令牌</param>
        /// <returns>验证结果</returns>
        (bool isValid, string userId) ValidateToken(string token);
        
        /// <summary>
        /// 刷新JWT令牌
        /// </summary>
        /// <param name="token">当前JWT令牌</param>
        /// <param name="refreshToken">刷新令牌</param>
        /// <returns>新的JWT令牌</returns>
        Task<(bool success, string message, string newToken)> RefreshTokenAsync(string token, string refreshToken);
    }
}